Repository navigation
fix(api): answer 404 for a missing flow, element or pad on the property endpoints - #1162
Conversation
…ty endpoints The four element and pad property endpoints documented 404 for a flow that is not running and for a missing element or pad, but mapped every error to 400. The state layer also reported a missing or stopped flow as an invalid flow. A stopped flow is now FlowNotRunning at those four lookups, and the handlers map the not-found errors to 404. Bad values and properties that cannot change stay 400. Closes #928 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0199NeykvEJAk7jqit4PwX4J
srperens
left a comment
There was a problem hiding this comment.
Area: REST API, error status codes on the property endpoints
The PR adds a typed PipelineError::FlowNotRunning and property_error_status (backend/src/api/flows.rs:1128), which maps a missing flow, pipeline, element or pad to 404 by variant, not by message text, across all four handlers. That is the right fix. The GET annotations now match what the handlers return.
Neighbours: #806 edits other hunks of flows.rs and state/mod.rs; I did not check a merge. #1154 regenerates openapi.json, which this PR leaves alone.
I found nothing wrong in the change. The test drives the real router through all four endpoints, should fail if the fix is reverted, and uses only core/base elements, so it runs in CI.
Out of scope here, but the same problem remains elsewhere:
- At this head, 14 other state methods still return
InvalidFlow("Pipeline not running for flow: ...")(the PR body says ten). Their endpoints keep answering 400. get_block_thumbnailpicks 404 by string match (flows.rs:2599). Both could reuseFlowNotRunningin a follow-up.
Closes #928
Problem
The four element and pad property endpoints (
GET/PATCH .../elements/{element_id}/propertiesand.../pads/{pad_name}/properties) document404for a flow that is not running and for a missing element or pad. They answered400for every error, so a client could not tell "not there" from "bad value". A flow that does not exist was reported asInvalid flow: Pipeline not running, the same error a bad flow definition gives elsewhere. Checked on current main with read-only GETs: a missing flow and a stopped flow both answered 400 on both endpoints.Change
PipelineError::FlowNotRunning. The four state lookups (update_element_property,get_element_properties,update_pad_property,get_pad_properties) return it instead ofInvalidFlowwhen the flow has no pipeline.property_error_status()inapi/flows.rsmapsFlowNotFound,FlowNotRunning,ElementNotFoundandPadNotFoundto 404, and everything else to 400 (InvalidProperty,PropertyNotMutable, ...). The four handlers use it. The 500 for "updated but failed to read back" is unchanged.Rejected: reusing
FlowNotFoundfor a stopped flow. The flow exists, and the message would say it doesn't.Evidence
property_not_found_status_test::missing_flow_element_or_pad_answers_404. With thebackend/srcchanges reverted it fails on its first call:GET /api/flows/00000000-0000-4000-8000-000000000928/elements/src/properties answered 400 Bad Request, expected 404 Not Found.openapi_testpasses without updatingopenapi.json.Tests
Ran on macOS (GStreamer 1.28.6):
cargo test --test property_not_found_status_test --test openapi_test: both pass.cargo clippy --all-targets: clean.The new test needs
videotestsrc(plugins-base) andfakesink(core), which every CI test job installs. It does not skip.Not run: the full backend test suite locally.
For the reviewer
Invalid flow: Pipeline not running for flow: <id>toFlow not running: <id>. The MCPget_element_properties/update_element_propertytools pass it through as text. Nothing in the repo matches on the old text.Flow not running: the state lookup only sees the running pipelines.Out of scope
Ten other state methods still report a stopped flow as
InvalidFlow("Pipeline not running ...")(vision mixer, loudness, recorder split, ...). Their handlers are not part of #928 and map errors their own way.🤖 Generated with Claude Code
https://claude.ai/code/session_0199NeykvEJAk7jqit4PwX4J